﻿using System.Collections.Generic;
namespace MS.Common.Context
{
    public class DicContext
    {
        private static DicContext dicContext = new DicContext();

        public static DicContext DicCacheList
        {
            get { return dicContext; }
            set { dicContext = value; }
        }

        private Dictionary<string, object> dic = new Dictionary<string, object>();

        public List<T> GetListByTableName<T>()
        {
            string tableName = typeof(T).Name;
            if (!string.IsNullOrEmpty(tableName))
            {
                if (dic.ContainsKey(tableName))
                {
                    return (List<T>)dic[tableName];
                }
            }
            return null;
        }

        public void SetListByTableName(string tableName, object list)
        {
            if (dic.ContainsKey(tableName))
            {
                dic[tableName] = list;
            }
            else
            {
                dic.Add(tableName, list);
            }
        }

    }
}
